package com.ls.shiroWithJwt.shiro.token;

import org.apache.shiro.authc.AuthenticationToken;

/**
 * jwt token
 */
public class JwtAuthenticationToken implements AuthenticationToken {

    private String jwt;
    private String userName;
    private String password;
    private String sysCode = "";

    public JwtAuthenticationToken(String jwt) {
        this.jwt = jwt;
    }

    public JwtAuthenticationToken(String jwt, String userName, String password) {
        this.jwt = jwt;
        this.userName = userName;
        this.password = password;
    }

    public JwtAuthenticationToken(String userName, String password) {

        this.userName = userName;
        this.password = password;
    }

    public String getJwt() {
        return jwt;
    }

    public void setJwt(String jwt) {
        this.jwt = jwt;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public Object getPrincipal() {

        return jwt;
    }

    @Override
    public Object getCredentials() {
        if(userName!=null && !"".equals(userName.trim()))
            return password;
        return "";
    }

    public String getSysCode() {
        return sysCode;
    }

    public void setSysCode(String sysCode) {
        this.sysCode = sysCode;
    }
}
